<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');


class server extends CI_Controller {
	public function __construct(){
		parent::__construct();	
	}
	
	function index (){
		
	}
	function rsync(){
		shell_exec('bash  /var/www/gamehaynhat.com/bash/update.sh 2>&1');
		
	}
	
	function rsync2(){
		echo time();
		echo shell_exec('bash  /var/www/gamehaynhat.com/bash/update.sh 2>&1');
		  
	}
	function t2(){
		echo time();
		echo shell_exec('ssh-copy-id -i /var/www/.ssh/id_rsa.pub rsync@10.0.2.35 2>&1');
		  
	}
	function auto_sync(){
		$this->load->model("sserver");
		$this->sserver->rsync();
	}
	
	function mainserver_downloadfile(){
		$url = $this->input->post("url");
		$patch = $this->input->post("path");
		$is_cache = $this->input->post("iscache");
		if($url && $patch && $is_cache){
			$this->load->model("simage");
			$this->simage->create_dirs($patch);
			$content = file_get_contents($url);
			file_put_contents($patch, $content);
			if($is_cache == 1)
				$this->simage->cache($patch);
			$this->auto_sync();
			die($patch);
		}
	}
}
?>